package edu.pku.sei.transformation.editor.controller.commands.link;

import edu.pku.sei.modeler.model.core.MetaModelElement;
import edu.pku.sei.transformation.editor.model.constraint.Constraint;
import edu.pku.sei.transformation.editor.model.constraint.ConstraintConnection;
import edu.pku.sei.transformation.editor.model.constraint.IConstrainableElement;

public class ConstraintConnectionDeleteCommand extends
		AbstractLinkDeleteCommand<ConstraintConnection, IConstrainableElement, Constraint> {
	public ConstraintConnectionDeleteCommand(ConstraintConnection link, IConstrainableElement source, Constraint target) {
		super(link, source, target);
	}
	
	@Override
	public void undo() {
		link.setConstraint(target);
		link.setContext((MetaModelElement)source);
		source.getConstraintConnections().add(link);
		target.setConnection(link);
	}
	
	@Override
	public void execute() {
		link.setConstraint(null);
		link.setContext(null);
		source.getConstraintConnections().remove(link);
		target.setConnection(null);
	}
}
